home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
HFTUBE.ZIP
/
TUBEPRE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-04-02
|
3KB
|
82 lines
Program TubePre;
{$M 4096,0,0}
Uses Crt;
Var Line,Err:Byte;
X,Y:LongInt;
Rm,A:Real;
Segm,Point,LinePos:Word;
Rmax:Array[0..519] Of Real;
LineLen:Array[0..255] Of Byte;
Fil:File;
FilT:Text;
Procedure WriteH(Val:Byte);
Const HStr:String='0123456789ABCDEF';
Begin
Write(FilT,'0',HStr[1+Val Shr 4],HStr[1+Val And 15],'h,');
End;
Begin
{ allocate required amount of memory }
Asm Mov Err,00h
Mov Ah,48h
Mov Bx,0FA0h
Int 21h
Adc Err,00h
Mov Segm,Ax
End;
If Err>0 Then Begin WriteLn('Not Enough Memory!!!'); Halt(1); End;
{ Calculate radiuses to the specified edge on the screen from the centre }
Point:=0;
For Y:=0 to 99 Do Begin Rmax[Point]:=Sqrt(Y*Y+25281); Inc(Point); End;
For X:=-159 to 0 Do Begin Rmax[Point]:=Sqrt(X*X+9801); Inc(Point); End;
For X:=0 to 159 Do Begin Rmax[Point]:=Sqrt(X*X+9801); Inc(Point); End;
For Y:=99 downto 0 Do Begin Rmax[Point]:=Sqrt(Y*Y+25281); Inc(Point); End;
{ Calculate each voxel line length and output result to the file }
Assign(FilT,'POKS'); ReWrite(FilT); Point:=0;
For X:=0 to 127 Do Begin
If X=0 Then Rm:=106.96101053 Else If X=127 Then Rm:=66.598365046 Else Begin
A:=-(Pi/2)*(1-X/127); A:=Sin(A)/Cos(A);
If A>-1.6060606 Then
Rm:=0.672710758*Rmax[Round(259+99*A)] Else
Rm:=0.672710758*Rmax[Round(-159/A)];
End; WriteH(Round(Rm+1)); LineLen[Point]:=Round(Rm); Inc(Point); End;
WriteLn(FilT);
For X:=127 downto 0 Do Begin
If X=0 Then Rm:=106.96101053 Else If X=127 Then Rm:=66.598365046 Else Begin
A:=-(Pi/2)*(1-X/127); A:=Sin(A)/Cos(A);
If A>-1.6060606 Then
Rm:=0.672710758*Rmax[Round(259+99*A)] Else
Rm:=0.672710758*Rmax[Round(-159/A)];
End; WriteH(Round(Rm+1)); LineLen[Point]:=Round(Rm); Inc(Point); End;
Close(FilT);
{ Calculate bitmap pointer table, which will be used to read data from }
{ specified position of bitmap and move it to the screen. Output result }
{ to the file }
Point:=$F9FE;
For Y:=99 downto 0 Do Begin
For X:=-159 to 0 Do Begin
If X<>0 Then Line:=Round(127*Abs(ArcTan(Y/X))/(Pi/2)) Else Line:=127;
If Y=0 Then Rm:=159 Else If X=0 Then Rm:=99 Else
If X/Y>-1.6060606 Then
Rm:=Rmax[Round(259+99*X/Y)] Else
Rm:=Rmax[Round(-159*Y/X)];
LinePos:=Round((LineLen[Line]-1)*(1-Sqrt(X*X+Y*Y)/Rm));
MemW[Segm:Point]:=LinePos*512+Line;
Dec(Point,2); End;
For X:=0 to 159 Do Begin
If Y<>0 Then Line:=Round(128+127*Abs(ArcTan(X/Y))/(Pi/2)) Else Line:=255;
If Y=0 Then Rm:=159 Else If X=0 Then Rm:=99 Else
If X/Y<1.6060606 Then
Rm:=Rmax[Round(260+159*(X/Y)/1.6060606)] Else
Rm:=Rmax[Round(420+99*(1-1.6060606*(Y/X)))];
LinePos:=Round((LineLen[Line]-1)*(1-Sqrt(X*X+Y*Y)/Rm));
MemW[Segm:Point]:=LinePos*512+Line;
Dec(Point,2); End; End;
Assign(Fil,'TUBE.DAT'); ReWrite(Fil,1);
BlockWrite(Fil,Mem[Segm:0],64000); Close(Fil);
End.